<template>
    <div class="echart-chart">
        <div class="inside">
            <header><i class="el-icon-location-outline"></i> 房价环比同比及预测（本邮编）</header>
            <div class="chartBox clearfix">
                <aside v-show="!chartNoDataShow">
                    <p>环比：{{ isNull0(mom) }}</p>
                    <p>同比：{{ isNull0(yoy) }}</p>
                    <p>季度环比增幅：{{ isNull0(qoq) }}</p>
                    <p>近5年来平均年增幅：{{ isNull0(y_5) }}</p>
                    <p>近10年来平均年增幅：{{ isNull0(y_10) }}</p>
                    <p>历史房价最高的月份：{{ isNull0(peak_month) }}</p>
                    <p>历史房价最高的季度：{{ isNull0(peak_quarter) }}</p>
                    <p>历史最高平均房价：{{ isNull0_USD(peak_zhvi) }}</p>
                    <p>目前平均房价：{{ isNull0_USD(zhvi) }}</p>
                    <p>目前房价与历史房价相比：{{ isNull0(pct_fall_from_peak) }}</p>
                </aside>
                <h4 ref="Zip_Zhvi_Summary_AllHomes_NoData" v-show="chartNoDataShow"></h4>
            </div>
            <p v-show="false">{{getzipcode}}</p>

        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                chartNoDataShow: false, //判断是否有无数据
                mom: '', //环比
                yoy: '', //同比
                qoq: '', //季度环比增幅
                y_5: '', //近5年来平均年增幅
                y_10: '', //近10年来平均年增幅
                peak_month: '', //历史房价最高的月份
                peak_quarter: '', //历史房价最高的季度
                peak_zhvi: '', //历史最高平均房价
                zhvi: '', //目前平均房价
                pct_fall_from_peak: '', //目前房价与历史房价相比

            }
        },
        computed: {
            //房源详情页图表使用——本房源所在邮zipcode
            getzipcode() {
                if(this.$store.getters.get_houseDetailsZipcode){
                    //获取房价环比同比及预测（本邮编）数据
                    this.get_Zip_Zhvi_Summary_AllHomes();
                }
                return this.$store.getters.get_houseDetailsZipcode
            }

        },
        created() {
        },
        mounted() {
        },
        methods: {
            //获取房价环比同比及预测（本邮编）数据
            get_Zip_Zhvi_Summary_AllHomes() {
                this.$get('/analysis/zhvi/73/'+ this.$store.getters.get_houseDetailsZipcode).then(res => {
                    if (res.status == 0) {
                        if(res.data != null){
                            this.chartNoDataShow = false;
                            this.mom = res.data.mom ? (res.data.mom * 100).toFixed(2) +'%' : 0;
                            this.yoy = res.data.yoy ? (res.data.yoy * 100).toFixed(2) +'%' : 0;
                            this.qoq = res.data.qoq ? (res.data.qoq * 100).toFixed(2) +'%' : 0;
                            this.y_5 = res.data.y_5 ? (res.data.y_5 * 100).toFixed(2) +'%' : 0;
                            this.y_10 = res.data.y_10 ? (res.data.y_10 * 100).toFixed(2) +'%' : 0;
                            this.peak_month = res.data.peak_month;
                            this.peak_quarter = res.data.peak_quarter;
                            this.peak_zhvi = res.data.peak_zhvi;
                            this.zhvi = res.data.zhvi;
                            this.pct_fall_from_peak = res.data.pct_fall_from_peak ? (res.data.pct_fall_from_peak * 100).toFixed(2) +'%' : 0;
                        }else{
                            this.chartNoDataShow = true;
                            this.$refs.Zip_Zhvi_Summary_AllHomes_NoData.innerText = '暂未查询到数据！';
                        }
                    } else {
                        this.chartNoDataShow = true;
                        this.$refs.Zip_Zhvi_Summary_AllHomes_NoData.innerText = res.msg;
                    }
                });
            },
        },
        components: {}
    }
</script>

<style scoped lang="less" type="text/less">
</style>
